package com.ccl.bigevent.validation;

import com.ccl.bigevent.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * @Title: StateValidation
 * @Author ccl
 * @Package IntelliJ IDEA
 * @Date 2024/10/26 14:08
 * @description:
 */
public class StateValidation implements ConstraintValidator<State, String> {
    private final String published = "已发布";
    private final String draft = "草稿";
    @Override
    public boolean isValid(String state, ConstraintValidatorContext constraintValidatorContext) {
        if (state == null || !(state.equals(draft) && state.equals(published))){
            return false;
        }
        return true;
    }
}
